using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DTO;
using BUS;
using DAL;
using Utility;

public partial class themhinhanh : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Loaddl();
    }
    protected void bt_them_Click(object sender, EventArgs e)
    {

        tbhinhanhDTO ha = new tbhinhanhDTO();


        if (FileUpload1.HasFile)
        {
            string filename = FileUpload1.PostedFile.FileName;
            FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Admin/image/thump") + filename);
            System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("~/Admin/image/thump") + filename);
            ImageUtility.MakeThumbnailPhoto(img, 70, 70, Server.MapPath("~/Admin/image/hinhnho"), filename);

            ha.Tenhinhanh = filename;
        }
        else
        {
            ha.Tenhinhanh = ConfigurationManager.AppSettings["NoImage"];
        }

        ha.Mota = txt_mota.Text;
        ha.Masp = int.Parse(Session["idsp"].ToString());

        tbhinhanhBUS.Insert(ha);
    }

    private void Loaddl()
    {
        int h = int.Parse(Session["idsp"].ToString());
        tbsanphamDTO k = tbsanphamBUS.GetByID(h);
        lb_tensp.Text = k.Tensp.ToString();
    }

}
